<?php

require_once './application/core/CoreBase.php';

class ToolbarCore extends CoreBase
{
    public function __construct( &$controller )
    {
        parent::__construct( $controller );
    }
    
    public function GetToolBar($toolbar)
    {
        $session = new zend_session_namespace('session');
        $f = './application/configuration/toolbar/toolbar_' . $session->lang . '.ini';
        $r = fopen($f, 'r');
        $content = fread($r, filesize($f));
        fclose($r);$json = Zend_Json::decode($content);
        $i = 0;
        $html = "";
        while (isset($json[$toolbar][$i]))
        {
            $item = $json[$toolbar][$i]["item"];
            //$html .= "<li>";
            $classCSS = "";
            if ($i % 2 == 0) {
            	$classCSS = "toolbaritembackground1";
            } else {
            	$classCSS = "toolbaritembackground2";
            }
            $html .= "<a class='toolbaritem " . $classCSS . "' style='color:#ffffff;'";
            $html .= " onclick=\"" . $item["onclick"] . "\"";
	    if (isset($item["id"]) && $item["id"] != '') {
		     $html .= " id=\"" . $item["id"] . "\"";
	    }
            $html .= ">";
            /*$html .= "<img src='" . $this->_controller->_urlBase . "/" . $item["image"] . "' border='0' width='10'/>";*/
            $html .= "" . $item["titre"] . "";
            $html .= "</a>";
            //$html .= "</li>";
            $i++;
        }
        return $html;
    }
}
